Skip to main content

Drawings Repository

  • Stores data for all library logic related to drawings.
  • Consists of 4 components:
    • DrawingsLineWidthRepo - selected line thickness for drawings
    • TypesRepo - selected drawings from the general list displayed in the corresponding toolbar
    • SnapshotsRepo - snapshots of drawings created on the chart
    • FirstClickRepo - initial press of "Magnet" and "Brush" buttons on the drawing toolbar - a hint should be shown on the first press, and it also stores whether the hint was shown after setting a text drawing

Repository interfaces:

/**
* Interface for storing data about the first press of "Magnet" and "Brush" buttons on the drawing toolbar.
* It also stores data about whether the Hint was shown after setting a text drawing.
*
* Implementation of this interface is mandatory for the library to function.
*
* Default implementation - [com.devexperts.dxcharts.lib.data.repo.default_repos.DefaultFirstClickRepo]
*/
interface DrawingsFirstClickRepo {
/**
* Method called when the "Magnet" button on the drawing toolbar is pressed.
* Returns true if the method was called for the first time, false otherwise.
*/
fun magnetModeClicked(): Boolean
/**
* Method called when the "Brush" button on the drawing toolbar is pressed.
* Returns true if the method was called for the first time, false otherwise.
*/
fun drawingModeClicked(): Boolean
/**
* Method called when a text drawing is set.
* Returns true if the method was called for the first time, false otherwise.
*/
fun drawingTextShowed(): Boolean
}
/**
* Interface for storing data about the selected line width of drawings.
*
* Implementation of this interface is mandatory for the library to function.
*
* Default implementation - [com.devexperts.dxcharts.lib.data.repo.DrawingsLineWidthRepo]
*
* @property minLineWidth Minimum line width
* @property maxLineWidth Maximum line width
*/
interface DrawingsLineWidthRepo {
val minLineWidth: Int
val maxLineWidth: Int
/**
* Method returns the currently set line width.
*/
fun getLineWidth(): Int
/**
* Method sets the current line width.
*
* @param px Line width in pixels
*/
fun setLineWidth(px: Int)
}
/**
* Interface for storing data about the selected drawings from the common list, displayed in the corresponding toolbar.
*
* Implementation of this interface is mandatory for the library to function.
*
* Default implementation - [com.devexperts.dxcharts.lib.data.repo.DrawingsTypesRepo]
*/
interface DrawingsTypesRepo {
/**
* Method for selecting a drawing from the common list of drawings and adding it to the toolbar.
*
* @param drawingType Drawing to be added to the toolbar
*/
fun selectDrawingType(drawingType: DrawingType)
/**
* Method for removing a drawing from the toolbar.
*
* @param drawingType Drawing to be removed from the toolbar
*/
fun deselectDrawingType(drawingType: DrawingType)
/**
* Method to get a list of selected drawings.
*/
fun getSelected(): Collection<DrawingType>
}
/**
* Interface for storing data about snapshots of drawings that have been drawn on the chart.
*
* Implementation of this interface is mandatory for the library to function.
*
* Default implementation - [com.devexperts.dxcharts.lib.data.repo.DrawingsSnapshotsRepo]
*/
interface DrawingsSnapshotsRepo {
/**
* Adds a new snapshot to the repository.
*/
fun addSnapshot(snapshot: AllDrawingsSnapshot)
/**
* Returns true if there is a snapshot before the current one, otherwise false.
*/
fun hasPreviousStep(): Boolean
/**
* Returns true if there is a snapshot after the current one, otherwise false.
*/
fun hasNextStep(): Boolean
/**
* Returns true if it is possible to clear the chart of drawings (current snapshot is not empty), otherwise false.
*/
fun canClear(): Boolean
/**
* Sets and returns the previous snapshot relative to the current one.
*/
fun previousStep(): AllDrawingsSnapshot?
/**
* Sets and returns the next snapshot relative to the current one.
*/
fun nextStep(): AllDrawingsSnapshot?
/**
* Returns the version of the current snapshot.
*/
fun currentVersion(): Int
}